﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.XSchEmA.Entity;

namespace Pixysoft.Framework.XSchEmA
{
    public interface IDbComparer
    {
        IDataTableCompareResult CompareTable(DatabaseSchema aDatabase, DatabaseSchema bDatabase);

        IColumnCompareResult CompareColumn(TableSchema aTable, TableSchema bTable);

        IDataTypeCompareResult CompareDataType(ColumnSchema aColumn, ColumnSchema bColumn);

        IPrimarykeyCompareResult ComparePrimaryKey(DatabaseSchema aDatabase, DatabaseSchema bDatabase);

        IForeignkeyCompareResult CompareForeignKey(DatabaseSchema aDatabase, DatabaseSchema bDatabase);

        IUniqueCompareResult CompareUnique(DatabaseSchema aDatabase, DatabaseSchema bDatabase);
    }

    public interface IDataTableCompareResult
    {
        List<TableSchema> ASuplusTables { get; }
        List<TableSchema> BSuplusTables { get; }
        List<KeyValuePair<TableSchema, TableSchema>> SameTables { get; }
    }

    public interface IColumnCompareResult
    {
        /// <summary>
        /// 是否拥有相同的字段，不检查字段类型
        /// </summary>
        bool IsSame { get;}
        List<ColumnSchema> ASuplusColumns { get; }
        List<ColumnSchema> BSuplusColumns { get; }
        List<KeyValuePair<ColumnSchema, ColumnSchema>> SameColumns { get; }
    }

    public interface IDataTypeCompareResult
    {
        bool IsSame { get; }
        bool IsSameColumn { get; }
        bool IsSameColumnName { get;  }
        bool IsSameDataTypeName { get; }
        bool IsSameDateType { get; }
        bool IsSameLength { get; }
        bool IsSameNullable { get; }
        bool IsSamePrecision { get; }
        bool IsSameScale { get; }
        bool IsSameTableName { get;  }
    }

    public interface IForeignkeyCompareResult
    {
        List<ForeignKeySchema> ASuplusFKs { get;  }
        List<ForeignKeySchema> BSuplusFKs { get;  }
        List<KeyValuePair<ForeignKeySchema, ForeignKeySchema>> SameForeignKeys { get;  }
    }

    public interface IPrimarykeyCompareResult
    {
        List<PrimaryKeySchema> ASuplusPKs { get;  }
        List<PrimaryKeySchema> BSuplusPKs { get;  }
        List<KeyValuePair<PrimaryKeySchema, PrimaryKeySchema>> SamePrimarykeys { get;  }
    }

    public interface IUniqueCompareResult
    {
        List<UniqueSchema> ASuplusUniques { get;  }
        List<UniqueSchema> BSuplusUniques { get;  }
        List<KeyValuePair<UniqueSchema, UniqueSchema>> SameUniques { get;  }
    }
}
